<template>
	<view class="shopList">
		<view class="title" :style="{'height': navHeight+statusBarHeight + 'px'}">
			<text class="iconfont iconhuaban73" @tap="$emit('close')"></text>
			<view class="serch"><text @tap="getProduct()" class="iconfont iconhuaban18"></text><input type="text"
					confirm-type="search" @confirm="getProduct()" placeholder="搜索店铺名称" /></view>
		</view>
		<cl-filter-bar>
			<text class="cl-filter-item" :class="{'active':order_type==='mix'}" @tap="changOrder('mix')">综合</text>
			<text class="cl-filter-item" :class="{'active':order_type==='sale'}" @tap="changOrder('sale')">销量</text>
		</cl-filter-bar>
		<view class="storeItem">
			<scroll-view scroll-y="true" @scrolltolower="scrolltolower">
				<view class="storeList" v-for="(item,index) in storeList" :key="index">
					<view class="row-1">
						<view class="col-1">
							<image :src="item.store_logo" mode=""></image>
							<view class="store">
								<text class="storeName">{{item.store_name}}</text>
								<text class="introduce">{{item.age}}年老店{{item.is_carry==1?' | 支持配送':''}}</text>
							</view>
						</view>
						<view class="col-2" @tap="$emit('sendPopupMsg',item,'store');$emit('close')">发送</view>
					</view>
					<view class="row-2">
						<scroll-view class="tab-scroll-view" :scroll-x="true">
							<view class="tab-item" v-for="(item2,index2) in item.push_product" :key="index2">
								<image :src="item2.main_imgurl" mode=""></image>
								<view class="price">￥{{item2.price}}</view>
							</view>
						</scroll-view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import customeApi from '@/service/custome.js'
	import clFilterBar from "../components/cl-uni/components/cl-filter-bar/cl-filter-bar.vue"
	import clFilterItem from "../components/cl-uni/components/cl-filter-item/cl-filter-item.vue"
	export default {
		data() {
			return {
				noMore: false,
				storeList: [],
				arr: [1],
				str: "",
				sort: "desc",
				filter: "",
				filterShow: false,
				page: 1, // 	第几页
				pagesize: 10, // 	第几页
				keyword: '', // 店铺名称
				order_type: '', // 	sale销量排序 mix综合排序
				cate_id_lst: '', // 	二级分类id 
				pcate_id: '' // 一级分类id 
			}
		},
		components: {
			clFilterBar,
			clFilterItem
		},
		computed: {
			navHeight() {
				return this.$store.state.system.navBarHeight
			}, // Nav栏高度
			statusBarHeight() {
				let systemInfo = uni.getSystemInfoSync()
				return systemInfo.statusBarHeight || 0
			}
		},
		created() {
			this.getProduct()
		},
		methods: {
			changOrder(item){
				this.order_type=item;
				this.getProduct()
			},
			getProduct(paging) {
				if (!paging) {
					this.page = 1;
				}
				customeApi.shops({
					page: this.page,
					pagesize: this.pagesize, // 	第几页
					keyword: this.keyword, // 店铺名称
					order_type: this.order_type, // 	sale销量排序 mix综合排序
					cate_id_lst: this.cate_id_lst, // 	二级分类id 
					pcate_id: this.pcate_id // 一级分类id 
				}).then(res => {
					if (res.code == 1) {
						if (this.page * this.pagesize >= res.data.count) {
							this.noMore = true;
						}else{
							this.noMore = false;
						}
						if (paging) {
							res.data.data.map(item => {
								this.storeList.push(item);
							});
						} else {
							this.storeList = res.data.data;
						}

					}
				})
			},
			scrolltolower() {
				if (this.noMore) {
					return
				};
				this.page++;
				this.getProduct(true);
			}
		}
	}
</script>

<style lang="scss">
	.shopList {
		overflow: hidden;
		display: flex;
		flex-direction: column;
		width: 100%;
		height: 100%;

		.title {
			display: flex;
			width: 100%;
			height: 88rpx;
			background: #F6F7FB;
			align-items: center;

			.iconhuaban73 {
				font-size: 36rpx;
				color: #333333;
				padding: 0 20rpx;
			}

			.serch {
				display: flex;
				align-items: center;
				width: 422rpx;
				height: 62rpx;
				background: #FFFFFF;
				border-radius: 34rpx;

				.iconhuaban18 {
					font-size: 32rpx;
					color: #939393;
					padding: 0 20rpx 0 10rpx;
				}

			}
		}

		.screen {
			display: flex;
			justify-content: space-around;
			align-items: center;
			height: 114rpx;
			background: #FFFFFF;
			color: #333333;
			font-size: 24rpx;
			border-radius: 24rpx 24rpx 0 0;

			.iconhuaban114 {
				font-size: 30rpx;
			}
		}

		.storeItem {
			flex: 1;
			min-height: 0;
			overflow-y: hidden;
			background: #F6F7FB;

			scroll-view {
				width: 100%;
				height: 100%;
			}

			.storeList {
				width: 686rpx;
				background: #FFFFFF;
				margin: 0 auto;
				border-radius: 8rpx;
				padding: 0 28rpx;
				margin-bottom: 28rpx;

				.row-1 {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 32rpx 0;

					.col-1 {
						display: flex;
						align-items: center;

						image {
							width: 76rpx;
							height: 76rpx;
							border-radius: 50%;
						}

						.store {
							display: flex;
							flex-direction: column;
							justify-content: space-between;
							height: 60rpx;
							margin-left: 16rpx;

							.storeName {
								font-size: 28rpx;
								color: #1A1C20;
							}

							.introduce {
								font-size: 20rpx;
								color: #939393;
							}
						}
					}

					.col-2 {
						width: 122rpx;
						height: 44rpx;
						line-height: 44rpx;
						text-align: center;
						border-radius: 20rpx;
						background: #C3AB7C;
						color: #fff;
						font-size: 28rpx;
					}
				}

			}

			.row-2 {
				padding-bottom: 24rpx;

				.tab-scroll-view {
					flex-direction: row;
					white-space: nowrap;

					.tab-item {
						display: inline-block;
						width: 200rpx;
						height: 200rpx;
						margin-right: 20rpx;
						position: relative;

						image {
							border-radius: 8rpx;
						}

						.price {
							position: absolute;
							bottom: 0;
							left: 0;
							width: 82rpx;
							height: 28rpx;
							line-height: 28rpx;
							text-align: center;
							background: #7A7A7A;
							font-size: 14rpx;
							color: #fff;
							border-radius: 0px 8rpx 0px 8rpx;
						}
					}
				}
			}
		}

	}
</style>
